
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By


from Driver.Driver import MDriver
from part import LogInFace
class BarFace:
    driver=''
    def __init__(self):
        self.driver=MDriver.driver
    # 进入首页查看功能栏
    def Come(self):
        LogInFace.LogInFace().Come()
        LogInFace.LogInFace().LogInScanfName("zhang")
        LogInFace.LogInFace().LogInScanfPass("12345")
        LogInFace.LogInFace().LogInTake()
    # 方便写代码
    def Qfind(self,name):
        self.driver.find_element(By.CSS_SELECTOR,name)
    # 检测界面元素
    def BarFace(self):
        # 检测图标
        self.Qfind("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > h1 > a > img")
        # 检测搜素框
        self.Qfind("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input")
        # 检测夜间模式
        self.Qfind("body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark > svg")

        # 检测消息
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a").click()
        # 检测消息信息
        self.Qfind("#index_div_message_list > div:nth-child(1) > div > div.col.text-truncate > a")
        # 检测X号
        self.Qfind("#index_message_offcanvasEnd > div.offcanvas-header > button")
        # 检测提示灯
        self.Qfind("#index_div_message_list > div:nth-child(1) > div > div:nth-child(1) > span")
        self.CloseBarMessage()

        # 检测头像
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.dropdown").click()
        # 头像元素
        self.Qfind("#index_user_profile")
        self.Qfind("#index_user_settings")
        self.Qfind("#index_user_logout")
        # 分类栏元素
        self.Qfind("#nav_board_index > a")
        self.Qfind("#topBoardList > li:nth-child(2) > a")
        self.Qfind("#topBoardList > li:nth-child(3) > a")
        self.Qfind("#topBoardList > li:nth-child(5) > a")
    # 搜索功能
    def BarSearch(self,name):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input").send_keys(name)
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div.nav-item.d-none.d-md-flex.me-3 > div > form > div > input").send_keys(Keys.ENTER)
    # 夜间模式
    def BarNight(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > a.nav-link.px-0.hide-theme-dark").click()
    # 查看消息
    def BarLookMessage(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page > header.navbar.navbar-expand-md.navbar-light.d-print-none > div > div > div:nth-child(2) > div > a").click()

    # 回复消息
    def BarReplayMessage(self,name):
        self.driver.find_element(By.CSS_SELECTOR,"#index_div_message_list > div:nth-child(2) > div > div.col.text-truncate > a").click()
        self.driver.find_element(By.CSS_SELECTOR,"#btn_index_message_reply > svg").click()
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_reply_receive_content").send_keys(name)
        self.driver.find_element(By.CSS_SELECTOR,"#btn_index_send_message_reply").click()
    # 关闭信息列表
    def CloseBarMessage(self):
        self.driver.find_element(By.CSS_SELECTOR,"#index_message_offcanvasEnd > div.offcanvas-header > button").click()
    # 点击头像
    def BarHead(self):
        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_avatar").click()
    # 进入个人帖子界面
    def BarGotoPersonalPost(self):
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_profile").click()
    # 进入个人中心界面
    def BarGotoPersonalCenter(self):
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_settings").click()
    # 退出登陆
    def BarLogOut(self):
        self.driver.find_element(By.CSS_SELECTOR,"#index_user_logout").click()
    # 进入首页
    def BarHome(self):
        self.driver.find_element(By.CSS_SELECTOR,"#nav_board_index > a").click()
    # 进入Java板块
    def BarGoJava(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(2) > a").click()
    # 进入C++板块
    def BarGoCpp(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(3) > a").click()
    # 进入MySQL板块
    def BarGoMySQL(self):
        self.driver.find_element(By.CSS_SELECTOR,"#topBoardList > li:nth-child(5) > a").click()


